from typing import *


class Solution:

    def checkInclusion(self, s1: str, s2: str) -> bool:
        m, n = len(s1), len(s2)
        hash = DefaultDict(int)
        for s in s1:
            hash[s] += 1
        for i, v in enumerate(s2):
            hash[v] -= 1
            if i >= m:
                hash[s2[i - m]] += 1
            if i >= m - 1:
                c = True
                for o, p in hash.items():
                    if p != 0:
                        c = False
                if c: return True
        return False


s = Solution()
print(s.checkInclusion(s1="ab", s2="eidbaooo"))
print(s.checkInclusion(s1="ab", s2="eidboaoo"))
